package com.gupao.xhc.homework.zookeeper.chosemaster;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;

import org.I0Itec.zkclient.ZkClient;
import org.I0Itec.zkclient.serialize.SerializableSerializer;

public class ChoseMaster {

    public static String CONNECTSTRING = "192.168.1.106:2181,192.168.1.107:2181," +
            "192.168.1.108:2181,192.168.1.109:2181";
    public static String MASTER_PATH = "/Master";
    public static int competitorNum = 5;
    
    public static void main(String[] args) throws InterruptedException {

    	CountDownLatch downLatch = new CountDownLatch(competitorNum);
        for(int i=0; i<competitorNum; i++){
            ZkClient zkClient = new ZkClient(CONNECTSTRING, 5000, 5000, new SerializableSerializer());
            MasterCompetitor mc = new MasterCompetitor(zkClient, "name" + i, downLatch);
            new Thread(mc).start();
            downLatch.countDown();
        }
        
        
    }
}

